package main

import (
	"fmt"
	"sync"
	"sync/atomic"
)

// 原子操作

var xActomic int64
var wgg sync.WaitGroup

func addActomic() {
	atomic.AddInt64(&xActomic, 1)
	wgg.Done()
}
func main() {
	wgg.Add(10000)
	for i := 0; i < 10000; i++ {
		go addActomic()
	}
	wgg.Wait()
	fmt.Println(xActomic) // 10000
}
